package com.example.data;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class CityOperation {
	private Context context;

	public CityOperation(Context context) {
		this.context = context;

	}

	public boolean addCtiy(String city, int id) {
		return true;
	}

	public boolean deleteCity(String city) {

		return true;
	}

	public int searchCityID(String city) {

		return 1;
	}

	public String[] searchItem(String cityName) {
		DbHelper dbhelper = new DbHelper(context, "weather");
		SQLiteDatabase db = dbhelper.getReadableDatabase();

		String[] value = new String[1];
		value[0] = cityName + "%";
		Cursor cursor = db.rawQuery("select *from weather where city like ?",
				value);
		String[] citys = new String[cursor.getCount()];
		while (cursor.moveToNext()) {
			String city = cursor.getString(0);
			int id = cursor.getInt(1);

			citys[cursor.getPosition()] = city;
		}
		return citys;
	}
}
